﻿@{
    Layout = null;
}
<script type="text/javascript">

    ///<summary>
    /// ClaimMore页面类
    ///</summary>
    function ClaimMore() {
        ///<summary>
        /// 初始化页面
        ///</summary>
        this.init = function () {
            initSelectType();
            initClaimGrid();
            initSearchChange();
        };
        ///<summary>
        /// 初始化 grid
        ///</summary>
        function initClaimGrid() {
            $("#list_Home_ClaimMore").jqGrid({
                url: "/Home/ClaimMore",
                datatype: "json",
                mtype: "post",
                colNames: ['WorktaskInsId', 'operatorInsId', '业务名称', '任务名称', '提交人', '操作时间', '操作'],
                colModel: [
                        { name: 'WorktaskInsId', index: 'WorktaskInsId', align: "center", sortable: false, hidden: true },
                        { name: 'operatorInsId', index: 'operatorInsId', align: "center", sortable: false, hidden: true },
                        { name: 'FlowInsCaption', index: 'FlowInsCaption', formatter: formatCaption, width: 300, align: "center", sortable: false },
                        { name: 'TaskCaption', index: 'TaskCaption', align: "center", width: 150, sortable: false },
                        @if("ViewBag.WorkStatus"=="2")
                        {
                          @:{ name: 'pOperatedDes', index: 'pOperatedDes', width: 100, align: "center", sortable: false },
                          @:{ name: 'OperDateTime', index: 'OperDateTime', align: "center", width: 100, sortable: false },
                        }else
                        {
                            @:{ name: 'OperatedDes', index: 'OperatedDes', width: 100, align: "center", sortable: false },
                            @:{name: 'taskEndTime', index: 'taskEndTime', align: "center", width: 100, sortable: false },
                        }
                        { name: "WorkFlowId", index: "WorkFlowId", width: 80, align: "center", sortable: false, hidden: false, formatter: formatOption }
                       ],
                beforeRequest: function () {
                    $(this).jqGrid('setGridParam', { postData: {"workType": $("#workType_Home_ClaimMore").val(),"workStatus": $("#workStatus_Home_ClaimMore").val()} });
                },
                loadError: function (xhr, status) {
                    alertMsg.error(xhr.responseText);
                },
                loadComplete: function (xhr) {
                    $("#list_Home_ClaimMore a[target=_navTab]").each(function () {
                        $(this).click(function (event) {
                            var $this = $(this);
                            var title = $this.attr("title") || $this.text();
                            var tabid = $this.attr("rel") || "_blank";
                            var fresh = eval($this.attr("fresh") || "true");
                            var external = eval($this.attr("external") || "false");
                            var url = $this.attr("href");
                            DWZ.debug(url);
                            if (!url.isFinishedTm()) {
                                alertMsg.error($this.attr("warn") || DWZ.msg("alertSelectMsg"));
                                return false;
                            }
                            navTab.openTab(tabid, url, { title: title, fresh: fresh, external: external });
                            event.preventDefault();
                        });
                    });
                    var ajaxbg = $("#background,#progressBar,#lui_Claimed_Home_Index");
                    ajaxbg.hide();
                },
                rownumbers: true,
                autowidth: true,
                shrinkToFit: true,
                multiselect: false,
                multiselectWidth: 50,
                sortable: false,
                viewrecords: true,
                sortorder: "desc",
                jsonReader: {
                    repeatitems: false
                },
                rowNum: -1,
                altRows: true,
                height: $("#tabContent").innerHeight() - $(".panelBar").height() - 28
            }).navGrid('#pager', { edit: false, add: false, del: false, refresh: false, search: false });
        };
        ///<summary>
        /// 格式化 业务名称列 上的链接
        ///</summary>
        function formatCaption(cellvalue, options, rowObject) {
            if($("#workStatus_Home_ClaimMore").val()>2)
                return'<a href="/WorkFlow/View/Index?worktaskInsid=' + rowObject.WorktaskInsId + '&operatorInsId=' + rowObject.operatorInsId + '" target="_navTab" rel="ctrlworkflow" style="color:Blue">' + rowObject.FlowInsCaption + '</a>';
            else
                return '<a href="/WorkFlow/Ctrl/Index?worktaskInsid=' + rowObject.WorktaskInsId + '&operatorInsId=' + rowObject.operatorInsId + '" target="_navTab" rel="ctrlworkflow" style="color:Blue">' + rowObject.FlowInsCaption + '</a>';
        };
        ///<summary>
        /// 格式化 操作列 上的链接
        ///</summary>
        function formatOption(cellvalue, options, rowObject) {
            return '<a style="font-size:12px;margin-left:10px;color:red" title="流程图"  alt="查看流程图" href="/WorkFlow/WorkflowMap/Index?workflowId=' + rowObject.workflowId + '&workflowInsId=' + rowObject.workflowInsId + '" target="_navTab" rel="workflowmap" >查看流程图</a>';
        };
        ///<summary>
        /// 绑定搜索条件变化的事件
        ///</summary>
        function initSearchChange() {
            $("#Home_ClaimMore .panelBar").find("select,input[type='text']").change(function () {
                $("#list_Home_ClaimMore").trigger("reloadGrid");
            });
        }
        ///<summary>
        /// 默认选择的下拉框
        ///</summary>
        function initSelectType() {
            $("#workType_Home_ClaimMore").val(@ViewBag.WorkType);
            $("#workStatus_Home_ClaimMore").val(@ViewBag.WorkStatus);
        }
    }

    $(document).ready(function () {
        new ClaimMore().init();
    });
</script>
<div class="page" id="Home_ClaimMore">
    @*顶部按钮*@
    <div class="panelBar">
        <ul class="toolBar">
            <li class="nobg">工作流类型：<select id="workType_Home_ClaimMore">
                <option value="">全部</option>
                <optgroup label="计量">
                    <option value="施工计量">施工计量</option>
                    <option value="设计计量">设计计量</option>
                    <option value="监理计量">监理计量</option>
                    <option value="检测计量">检测计量</option>
                </optgroup>
                <optgroup label="申报">
                    @*<option value="将罚金申报">将罚金申报</option>*@
                    <option value="索赔申报">索赔申报</option>
                    <option value="材差申报">材差申报</option>
                    <option value="计日工申报">计日工申报</option>
                    <option value="工程结算申报">工程结算申报</option>
                </optgroup>
            </select></li>
            <li class="nobg">工作流状态：<select id="workStatus_Home_ClaimMore">
                <option value="1">新到工作</option>
                <option value="2">待办工作</option>
                <option value="3">已办未批复</option>
                <option value="4">已批复工作</option>
            </select></li>
        </ul>
    </div>
    <div>
        <table id="list_Home_ClaimMore">
        </table>
    </div>
</div>
